package com.open.capacity.reimburse.controller;

import java.util.List;
import java.util.Map;

import com.open.capacity.commons.Result;
import com.open.capacity.reimburse.entity.BaseBgtEco;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import com.open.capacity.reimburse.entity.BasePayItemBgtEco;
import com.open.capacity.reimburse.service.BasePayItemBgtEcoService;

import com.open.capacity.commons.PageResult;

import javax.validation.Valid;

/**
 * 支出事项-经济科目
 *
 * @author
 * @email
 * @date 2023-11-01 11:17:21
 */
@RestController
@RequestMapping("basepayitembgtecos")
@Api(tags = "支出事项-经济科目")
public class BasePayItemBgtEcoController {

    @Autowired
    private BasePayItemBgtEcoService basePayItemBgtEcoService;

    /**
     * 列表
     */
    @RequestMapping("/findByPayitemId")
    @PreAuthorize("hasAnyAuthority('base_pay_item_bgt_eco:basepayitembgteco:list')")
    public Result findByPayitemId(String payitemId) {
        List<BaseBgtEco> list = basePayItemBgtEcoService.findByPayitemId(payitemId);
        return Result.succeed(list, "success");
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @PreAuthorize("hasAnyAuthority('base_pay_item_bgt_eco:basepayitembgteco:save')")
    public Result save(@RequestBody List<BasePayItemBgtEco> basePayItemBgtEcos) {
        basePayItemBgtEcoService.save(basePayItemBgtEcos);
        return Result.succeed("保存成功");
    }


    /**
     * 删除
     */
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("hasAnyAuthority('base_pay_item_bgt_eco:basepayitembgteco:delete')")
    public Result delete(@PathVariable String id) {
        basePayItemBgtEcoService.delete(id);
        return Result.succeed("删除成功");
    }

}
